﻿@*@model IEnumerable<Super.Entity.ActionPermissionRole>
    @{
        IEnumerable<Super.Entity.ActionPermissionRole> result = Model;
    }
    <style>
        .permission-list > dd > dl > dd {
            margin-left: 0px;
        }
    </style>
    <article class="page-container">
        <form class="form form-horizontal" id="form-article-add" action="/admin/role/RoleActionSet/?Id=@ViewBag.role.Id" method="post">
            <div>
                <h3>给角色设置权限项</h3>
                <p>
                    <h2>角色：@ViewBag.role.Name</h2>
                </p>
            </div>
            <div>
            @foreach (var controller in ViewBag.ControllerList)
            {
                    <dl class="permission-list">
                        <dt>
                            @if (controller.ParentId == 0)
                            {
                                <label>
                                    @controller.Description
                                    <input type="checkbox" value="" name="user-Character-0" id="user-Character-1">
                                    全选
                                </label>
                            }
                        </dt>

                        <dd>
                            <dl class="cl permission-list2">
                                <dd>
                                    @foreach (var action in (IEnumerable<Super.Entity.ActionPermission>)ViewBag.ActionList)
                                    {
                                        if (action.ParentId == controller.Id)
                                        {
                                            <label class="">
                                                <input type="checkbox" value="@action.Id" name="actionItem" @(result.Any(a => a.ActionPermissionId == action.Id) ? "checked=checked" : "")>
                                                @action.Description
                                            </label>
                                        }
                                    }
                                </dd>
                            </dl>
                        </dd>
                    </dl>
                }
                <input type="submit" class="btn btn-primary radius" value="保存" style="margin:20px 50%" />
            </div>
        </form>
    </article>
    <script type="text/javascript">
        $(function () {
            $(".permission-list>dt input:checkbox")
                .click(function () {
                    $(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
                });
        });
    </script>*@
